<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateIntegralRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('integral_records', function (Blueprint $table) {
            $table->increments('id')->comment('积分记录表');
            $table->integer('integral_num')->nullable()->comment('积分数量')->default(0);
            $table->tinyInteger('types')->nullable()->comment('类型（1收入；2支出）')->default(0);
            $table->tinyInteger('obj_source')->nullable()->comment('纪录来源（1邀请；2商品详情页领取）')->default(0);
            $table->integer('obj_id')->nullable()->comment('目标ID（user_id/goods_id）')->default(0);
            $table->integer('integral_num_after')->nullable()->comment('操作后的积分')->default(0);
            $table->string('explain', 255)->nullable()->comment('来源说明文字');
            $table->integer('user_id')->nullable()->comment('用户ID')->default(0);
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('integral_records');
    }
}
